/**
 * Created by MetaLab_Gu on 2016/5/4.
 */
angular.module('metalabPartnerApp').directive("metaHeader", function ($window) {
    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            var event = function () {
                var offset = parseInt(attrs['scrollDownOffset']) || 100;
                var scroll = (angular.element(window).scrollTop());
                var threshold = (element.height() + offset);
                if (scroll > threshold) {
                    element.addClass('active');
                } else {
                    element.removeClass('active');
                }
            };
            event();
            angular.element($window).bind('scroll', event);
        }
    };
});
